How To Build A Cold Email Automation Using N8N (FREE Template)

N8N Cold Email Automation

Sending personalized bulk emails just got easier with N8N + Google Sheets! In this guide, I’ll walk you through an entire workflow where you can send emails using either Gmail or your custom SMTP, and log the status back into your sheet.

This blog post includes:

  • 🛠️ Full n8n workflow JSON files
  • 💻 JavaScript snippets used
  • ⏱ Delay mechanism for spam prevention
  • ✅ Real-time email status logging

📌 Prerequisites

  • A free n8n instance (cloud or self-hosted)
  • Google account with access to Google Sheets
  • Gmail or SMTP email access
  • A Google Sheet with:
    • Sheet 1: List of leads (Name, Email)
    • Sheet 2: List of email templates (Subject, Body)

🔗 Download Resources

• Download Workflow JSON (For Gmail Node) : Download

• Download Workflow JSON (For SMTP Node) : Download

• Download Leads Sheet File (Sample) : Download

JavaScripts

  • Pick a random template JavaScript
// Get templates from previous node
const templates = items.map(item => item.json);

// Check if templates exist
if (!templates || templates.length === 0) {
  throw new Error('No templates found');
}

// Pick a random template
const index = Math.floor(Math.random() * templates.length);
const template = templates[index];

// Convert body to HTML
const bodyHtml = template.Body.replace(/\n/g, '<br>');

// Return in n8n-compatible format
return [
  {
    json: {
      subject: template.Subject,
      body: bodyHtml
    }
  }
];
  • Personalisation [name] JavaScript ( Set Node)
{{ $json.body.replace("[name]", $json["Name"] && $json["Name"].trim() !== '' ? $json["Name"].trim() : "there") }}
  • Send status JavaScript (Gmail version)
{{ $json.labelIds[0] }}
  • Send status (SMTP version)
{{ $json.response.includes("250 2.0.0 Ok") ? "SENT" : "Failed" }}
  • Timestamp
{{ new Date().toLocaleTimeString("en-GB", { timeZone: "Asia/Kolkata", hour12: false }) }}

🧠 Workflow Overview

Here’s what this automation does:

  1. Fetches leads from Sheet 1 (name + email)
  2. Fetches email templates from Sheet 2
  3. Picks one random template
  4. Replaces variables in the template (e.g., {{name}})
  5. Sends email using Gmail or SMTP
  6. Logs send status and timestamp back to Google Sheets
  7. Repeats with a delay between each

Leave a Reply

Your email address will not be published. Required fields are marked *

Keep Reading

Category Business Posted on

LeadPilot Installation Guide (Step-by-Step)

If you want to host LeadPilot on your VPS with a custom domain and SSL, this guide will walk you through the entire setup in two parts: Installing Node.js, PM2 & LeadPilot Configuring Domain, Nginx & SSL By the end, your app will be live on https://yourdomain.com with auto-renewing SSL. 🔐 Prerequisites A VPS (Ubuntu 22 or 24 works fine). Root access to your server. A domain na…
Continue reading
Category AI Posted on

How to Build a WhatsApp RAG AI Agent with n8n (Free Template)

Automating WhatsApp replies with AI can save hours of manual work for businesses. In this tutorial, we’ll build a WhatsApp RAG (Retrieval Augmented Generation) AI Agent using n8n and WhatsApp Business Cloud API. This agent will: ✅ Read incoming WhatsApp messages ✅ Use RAG (Retrieval Augmented Generation) for smarter, context-based replies ✅ Connect to your own knowledge base (Google Sheets, product da…
Continue reading